package com.yinhe.music.yhmusic.utils;

import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.util.Log;


/**
 * 可安全分发任务的Handler
 *
 */
public class SafeDispatchHandler extends Handler {
	public SafeDispatchHandler(Looper looper) {
		super(looper);
	}

    public SafeDispatchHandler(Looper looper, Callback callback) {
        super(looper, callback);
    }

    public SafeDispatchHandler() {
        super();
    }

    public SafeDispatchHandler(Callback callback) {
        super(callback);
    }

    @Override
    public void dispatchMessage(Message msg) {
        try {
            super.dispatchMessage(msg);
        } catch (Exception e) {
            Log.e("SafeDispatchHandler", e.getMessage(), e);
        } catch (Error error){
            Log.e("SafeDispatchHandler", error.getMessage(), error);
        }
    }
}
